/*
 * \brief  Client-side log text output session interface
 * \author Norman Feske
 * \date   2006-09-15
 */

/*
 * Copyright (C) 2006-2009 Norman Feske
 * Genode Labs, Feske & Helmuth Systementwicklung GbR
 *
 * This file is part of the Genode OS framework, which is distributed
 * under the terms of the GNU General Public License version 2.
 */

#ifndef _INCLUDE__LOG_SESSION__CLIENT_H_
#define _INCLUDE__LOG_SESSION__CLIENT_H_

#include <log_session/capability.h>
#include <base/ipc.h>
#include <base/lock.h>

namespace Genode {

	class Log_session_client : public Log_session
	{
		private:

			Msgbuf<256> _snd_msg, _rcv_msg;
			Ipc_client  _ipc_client;
			Lock        _lock;

		public:

			/**
			 * Constructor
			 */
			explicit Log_session_client(Log_session_capability session)
			: _ipc_client(session, &_snd_msg, &_rcv_msg) { }


			/***************************
			 ** Log session interface **
			 ***************************/

			size_t write(const char *string)
			{
				Lock::Guard lock_guard(_lock);
				size_t result = 0;
				_ipc_client << WRITE << Buffer(string) << IPC_CALL >> result;
				return result;
			}
	};
}

#endif /* _INCLUDE__LOG_SESSION__CLIENT_H_ */
